package com.dingreading.cloud.subject.service.impl;

import com.dingreading.cloud.subject.entity.Staff;
import com.dingreading.cloud.subject.entity.table.StaffTableDef;
import com.dingreading.cloud.subject.mapper.StaffMapper;
import com.dingreading.cloud.subject.service.StaffService;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.stereotype.Service;

/**
 * 服务层实现。
 *
 * @author Administrator
 * @since 2024-08-01
 */
@Service
public class StaffServiceImpl extends BaseServiceImpl<StaffMapper, Staff, StaffTableDef> implements StaffService {

    @Override
    protected StaffTableDef getTable() {
        return StaffTableDef.staff;
    }

    @Override
    public Staff getByUid(String uid) {
        return getMapper().selectOneByCondition(table.uid.eq(uid));
    }

    @Override
    public String getSubjectType(String uid) {
        QueryWrapper wrapper = QueryWrapper.create()
                .select(table.subjectType)
                .from(table)
                .where(table.uid.eq(uid));
        return getMapper().selectObjectByQueryAs(wrapper, String.class);
    }

    @Override
    public String getUsername(String uid) {
        QueryWrapper wrapper = QueryWrapper.create()
                .select(table.username)
                .from(table)
                .where(table.uid.eq(uid));
        return getMapper().selectObjectByQueryAs(wrapper, String.class);
    }

}
